<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>联网查询检验项目</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
    <script type="text/javascript" src="../../script/jquery-1.10.2.min.js"></script>
</head>
<body>
    <div class="container" id="container">
        <div id="divLXArea" class="weui_cells weui_cells_form" style="margin-top:10px">
            <div class="mainbutton">
                <a class="weui_btn weui_btn_primary" style="display:inline-block; width: 95%" href="javascript:;" id="btnLWCXStart" onclick="LWCXStart()">开  始</a>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">检测线号</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <select class="select" style="width: 200px" onchange="ChangeLineNum()" id="selectLineNum">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                        <option value="13">13</option>
                        <option value="14">14</option>
                        <option value="15">15</option>
                    </select>
                </div>
            </div>
            <div id="divKSSJ" class="weui_cells_title">录像时间:
                <sapn id="spKSSJInfo" style="color:red">未开始</sapn>
            </div>  
            <div id="divListHeader" class="weui_cells_title">
                <sapn id="spVehicleInfo"></sapn>
            </div>  
        </div>
        <div id="divList">
        </div>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cells_title">检验员建议</div>
            <div class="weui_cells weui_cells_form">
            </div>
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <textarea id="txtJYYJY" class="weui_textarea" placeholder="请输入建议" rows="3"></textarea>
                </div>
            </div>
            <div class="weui_cells_title">合格项汇总</div>
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                 <textarea class="weui_textarea" style="color: green" id="txtHGXM" readonly="readonly" placeholder="" rows="2"></textarea>
                </div>
            </div>
            <div class="weui_cells_title">不合格项汇总</div>
            <div class="weui_cell">
                 <div class="weui_cell_bd weui_cell_primary">
                 <textarea class="weui_textarea" style="color: red" id="txtBHGX" readonly="readonly" placeholder="" rows="2"></textarea>
                </div>
            </div> 
            <div class="weui_cells_title">详细不合格项汇总</div>
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                     <textarea class="weui_textarea" style="color: red" id="txtBHGX_Sub" readonly="readonly" placeholder="" rows="2"></textarea>
                </div>
            </div> 
            <div class="weui_cells_title">不判定项汇总</div>
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                     <textarea class="weui_textarea" id="txtPBXM" readonly="readonly" placeholder="" rows="2"></textarea>
                </div>
            </div> 
            <div class="weui_cells_title">联网查询结果</div>
            <div class="weui_cells weui_cells_form">
            </div>
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <textarea id="txtLWCXJGMS" class="weui_textarea"  rows="3"></textarea>
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">手机号码</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input id="txtSJHM" class="weui_input" placeholder="手机号码"/>
                    </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">联系地址</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input id="txtLXDZ" class="weui_input" placeholder="联系地址"/>
                    </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">邮政编码</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input id="txtYZBM" class="weui_input" placeholder="邮政编码"/>
                    </div>
            </div>
        </div>
       
        </br>
        <div class="mainbutton" id="divDZQM">
        <a class="weui_btn weui_btn_mini weui_btn_primary" style="display:inline-block; width: 29%" href="javascript:;" onclick="ShowDZQM(this)" id="btnShowDZQM" >显 示</a>
        <span style="display:inline-block; width: 2%"></span>
        <a class="weui_btn weui_btn_mini weui_btn_primary" style="display:inline-block; width: 29%" href="javascript:;" id="btnAddPhoto" onclick="SaveDZQM()"  >保 存</a>
        <span style="display:inline-block; width: 2%"></span>
        <a class="weui_btn weui_btn_mini weui_btn_primary" style="display:inline-block; width: 29%;" href="javascript:;" id="btnWGXM" onclick="ClearDZQM()"  >清 除</a> 
    </div> 
     <div class="space">
        
    </div> 
    <div class="mainbutton">
        <a class="weui_btn weui_btn_primary" href="javascript:;" id="btnSaveLWCX" onclick="SaveLWCX()">提交联网查询</a>            
        </div>   
    </div>
    <div class="space">
        
    </div>
</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
    var chkHGXM = [];
    var chkBHGX = [];
    var chkBHGX_SUB = [];
    var chkPBXM = [];
    var drawingBoard;
    apiready = function(){
        $("#spVehicleInfo").html(api.pageParam.PlateNum + ", " + api.pageParam.VIN);
        GetLWCXJYXM(api.pageParam.ID);
        GetLXKSSJ(api.pageParam.ID);

        //得到联网查询信息描述
        GetLWCX_MS(api.pageParam.ID);

        var vLineNum = $api.getStorage('LineNum');
        if(vLineNum != null)
        {
            $("#selectLineNum").val(vLineNum);
        }

        drawingBoard = api.require('drawingBoard');
        drawingBoard.hide();

        //是否显示电子签名
        GetIsShowDZQM();
    };

    //得到联网查询的车辆信息.
    function GetLWCX_MS(LWID)
    {
        var vUrlRead = $api.getStorage('ServerUrlRead');
        api.ajax({
            url:vUrlRead + '/WcfServices/GetLWCXVehicle/' + LWID,
            method: 'post',
            contentType: "application/json",
        }, function(ret, err) {
            if (ret.IsSuccess) {
               $("#txtLWCXJGMS").val(ret.Data.LWCXJGMS);
            }
        });
    }

    // 是否显示电子签名
    function GetIsShowDZQM()
    {
        var vUrlRead = $api.getStorage('ServerUrlRead');
        api.ajax({
            url:vUrlRead + '/WcfServices/PDAIsShowDZQM',
            method: 'post',
            contentType: "application/json",
        }, function(ret, err) {
            if (ret.PDAIsShowDZQMResult.IsSuccess) {
                var vIsShowDZQM = ret.PDAIsShowDZQMResult.Data;
                if(vIsShowDZQM == "1")
                {
                    $("#divDZQM").show();
                }
                else
                {
                    $("#divDZQM").hide();
                }
            }
        });
    }

    function after(iCount){
        $("#time").html(iCount);
        iCount=iCount-1;
        setTimeout(function(){
        if(iCount!=-1)
        {
            after(iCount);
                }
        },1000);
    }

    function GetLXKSSJ(paraID)
    {
        var vUrlRead = $api.getStorage('ServerUrlRead');
        var vClass = $("#btnLWCXStart").attr("class");
        var array=vClass.split(" "); 
        if(array[0] == "weui_btn_primary"||array[1] == "weui_btn_primary" || array[2] == "weui_btn_primary")
        {
            api.ajax({
                url:vUrlRead + '/WcfServices/GetLWCXStartTime/'+paraID,
                method: 'post',
                contentType: "application/json",
            }, function(ret, err) {
                if (ret.IsSuccess) {
                    $("#spKSSJInfo").html(ret.Message);
                }
            });
        }
    }

    function LWCXStart()
    {
        var vClass = $("#btnLWCXStart").attr("class");
        var array=vClass.split(" "); 

        var vEnable = false;
        for(var i = 0;i<array.length;i++)
        {
            if(array[i] == "weui_btn_primary")
            {
                vEnable = true;
                break;
            }
        }

        if(vEnable)
        {
            $("#btnLWCXStart").removeClass("weui_btn_primary");
            $("#btnLWCXStart").addClass("weui_btn_default");
            var vUrlWrite = $api.getStorage('ServerUrlWrite');
            var vUserCHName = $api.getStorage('UserCHName');
            var vUserSFZH = $api.getStorage('UserSFZH');
            var vJCXDH = $("#selectLineNum").val();
            api.ajax({
                url:vUrlWrite + '/WcfServices/LWCXStart/'+api.pageParam.ID +'/'+ vUserCHName+ '/'+ vUserSFZH+ '/'+vJCXDH,
                method: 'post',
                contentType: "application/json",
            }, function(ret, err) {
                if (ret.IsSuccess) {
                    $("#spKSSJInfo").html(ret.Data);
                    
                }
                else
                {
                     api.alert({
                         title: '提示',
                         msg:  ret.Message,
                         }, function(ret, err){
                         
                     });      
                    $("#btnLWCXStart").removeClass("weui_btn_default");
                    $("#btnLWCXStart").addClass("weui_btn_primary");                 
                }
            });
        }
    }

    function GetLWCXJYXM(paraID)
    {
         var vUrlRead = $api.getStorage('ServerUrlRead');
         api.ajax({
            url:vUrlRead + '/WcfServices/GetLWCXAllJYXM/'+ paraID,
            method: 'post',
            contentType: "application/json",
        }, function(ret, err) {
            if (ret.IsSuccess) {
                var vData = InitJYXMList(ret.Data);
            }
        });
    }

    function InitJYXMList(data)
    {
        var lstData = "<div id=\"divSubList\" class=\"weui_cells weui_cells_checkbox\">";
        for (var i = 0; i < data.length; i++) { 
            lstData += "<label class=\"weui_cell weui_check_label\" for=\"chkLst" + data[i].ID + "\" >";
            lstData += " <div class=\"weui_cell_bd weui_cell_primary\">";
            lstData += "   <p>" + data[i].XMID + "、" + data[i].XMMC + "</p>";
            lstData += " </div></label>";
            lstData += " <div style='width:100%; text-align:left; padding-left:20px;'>";
            if(data[i].IsBHGX)
            {
                var indexBHGX = $.inArray(data[i].XMID, chkBHGX); 
                if (indexBHGX < 0) {
                    chkBHGX.push(data[i].XMID);
                }

                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Pass"+ data[i].XMID +"' type=\"radio\" value='"+data[i].XMID+"' onclick='AddHGXM(this);'/>合格</label> ";
                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Fail"+ data[i].XMID +"' checked=\"checked\" type=\"radio\" value='"+data[i].XMID+"' onclick='AddBHGX(this);' />不合格</label>";
                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Ppdx"+ data[i].XMID +"' type=\"radio\" value='"+data[i].XMID+"' onclick='AddBPDX(this);'/>不判定</label>";
            }
            else if(data[i].IsPBXM)
            {
                var indexPBXM = $.inArray(data[i].XMID, chkPBXM); 
                if (indexPBXM < 0) {
                    chkPBXM.push(data[i].XMID);
                }

                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Pass"+ data[i].XMID +"' type=\"radio\" value='"+data[i].XMID+"' onclick='AddHGXM(this);'/>合格</label> ";
                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Fail"+ data[i].XMID +"' type=\"radio\" value='"+data[i].XMID+"' onclick='AddBHGX(this);' />不合格</label>";
                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Ppdx"+ data[i].XMID +"' type=\"radio\" checked=\"checked\" value='"+data[i].XMID+"' onclick='AddBPDX(this);'/>不判定</label>";
            }
            else
            {
                 var indexBJXM = $.inArray(data[i].XMID, chkHGXM); 
                if (indexBJXM < 0) {
                    chkHGXM.push(data[i].XMID);
                }

                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Pass"+ data[i].XMID +"' type=\"radio\"checked=\"checked\" value='"+data[i].XMID+"' onclick='AddHGXM(this);'/>合格</label> ";
                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Fail"+ data[i].XMID +"' type=\"radio\" value='"+data[i].XMID+"' onclick='AddBHGX(this);' />不合格</label>";
                lstData += " <label><input name='Pass"+ data[i].XMID +"' id='Ppdx"+ data[i].XMID +"' type=\"radio\"  value='"+data[i].XMID+"' onclick='AddBPDX(this);'/>不判定</label>";
            }

            if(data[i].IsBHGX)
            {
                lstData += "<div id=\"divSub"+data[i].XMID+"\" class=\"weui_cells weui_cells_checkbox\">";
            }
            else
            {
                lstData += "<div id=\"divSub"+data[i].XMID+"\" style=\"display:none;\" class=\"weui_cells weui_cells_checkbox\">";
            }

            for(var y=0;y<data[i].JYXM_SUB.length;y++)
            {
                lstData += "<label class=\"weui_cell weui_check_label\" for=\"chk"+data[i].JYXM_SUB[y].XMDH+"\">";
                lstData += "<div class=\"weui_cell_hd\">";
                if(data[i].JYXM_SUB[y].IsBHGX)
                {
                    lstData += "<input type=\"checkbox\" class=\"weui_check\" checked=\"checked\" name=\"chk"+data[i].JYXM_SUB[y].XMDH+"\" id=\"chk"+data[i].JYXM_SUB[y].XMDH+"\" value='"+data[i].JYXM_SUB[y].XMDH+"' onclick='AddBHGX_Sub(this)' >";

                    var indexBHGX_Sub = $.inArray(data[i].JYXM_SUB[y].XMDH, chkBHGX_SUB); 
                    if (indexBHGX_Sub < 0) {
                        chkBHGX_SUB.push(data[i].JYXM_SUB[y].XMDH);
                    }
                }
                else
                {
                    lstData += "<input type=\"checkbox\" class=\"weui_check\" name=\"chk"+data[i].JYXM_SUB[y].XMDH+"\" id=\"chk"+data[i].JYXM_SUB[y].XMDH+"\" value='"+data[i].JYXM_SUB[y].XMDH+"' onclick='AddBHGX_Sub(this)' >";
                }
                lstData += "<i class=\"weui_icon_checked\"></i>";
                lstData += "</div>";
                lstData += "<div style=\"text-align:left; \" class=\"weui_cell_bd weui_cell_primary\">";
                lstData += "<p>"+data[i].JYXM_SUB[y].XMMC+"</p>";
                lstData += "</div>";
                lstData += "</label>";
            }
           
            lstData += "</div>";
            lstData += " </div> ";
        }

        lstData += "</div>";
        $("#divList").append(lstData);

         ChangedItems();
    }

    function SaveLWCX()
    {
        var vClass = $("#btnSaveLWCX").attr("class");
        var array=vClass.split(" "); 

        var vEnable = false;
        for(var i = 0;i<array.length;i++)
        {
            if(array[i] == "weui_btn_primary")
            {
                vEnable = true;
                break;
            }
        }

        if(vEnable)
        {
            var vBHGX = $("#txtBHGX").val();

            if(vBHGX.length >0)
            {
                api.confirm({
                title: '提示',
                msg: '有不合格项目，是否继续提交？',
                buttons: ['是', '否']
                }, function(ret, err) {
                    var index = ret.buttonIndex;

                    if(index == 1)
                    {
                        SubmitResult();
                    }
                });
            }
            else
            {
               SubmitResult();
            }
        }
    }

    //提交最终结果
    function SubmitResult()
    {
        $("#btnSaveLWCX").removeClass("weui_btn_primary");
        $("#btnSaveLWCX").addClass("weui_btn_default");
        var vId = api.pageParam.ID;
        var vJYYJY = $("#txtJYYJY").val();
        var vJCXDH = $("#selectLineNum").val();
        var vHGXM = $("#txtHGXM").val();
        var vPBXM = $("#txtPBXM").val();
        var vBHGX = $("#txtBHGX").val();
        var vBHGX_Sub = $("#txtBHGX_Sub").val();
        var vLWCXJGMS =$("#txtLWCXJGMS").val();
        var vSJHM =$("#txtSJHM").val();
        var vLXDZ =$("#txtLXDZ").val();
        var vYZBM =$("#txtYZBM").val();
        var vJYY=$api.getStorage('UserCHName');
        var vJYYSFZH=$api.getStorage('UserSFZH');
        var vUrlWrite = $api.getStorage('ServerUrlWrite');

        $.ajax({
                type: 'Post',
                url: vUrlWrite + '/WcfServices/SubmitLWCXData',
                contentType: "application/json", //必须有
                async: false,
                dataType: "json", //表示返回值类型，不必须
                    //data: JSON.stringify({ 'UserName': 'admin', 'UserPwd': '123456' }),  //相当于 //data: "{'str1':'foovalue', 'str2':'barvalue'}",
                data: JSON.stringify({
                    'PId': vId,
                    'JYYJY': vJYYJY,
                    'JCXDH': vJCXDH,
                    'HGXM': vHGXM,
                    'PBXM': vPBXM,
                    'BHGX': vBHGX,
                    'BHGX_Sub':vBHGX_Sub,
                    'LWCXJGMS':vLWCXJGMS,
                    'SJHM':vSJHM,
                    'LXDZ':vLXDZ,
                    'YZBM':vYZBM,
                    'JYY':vJYY,
                    'JYYSFZH':vJYYSFZH
                }),
                success: function(ret) {
                   
                    if (ret.SubmitLWCXDataResult) {
                     
                        if(ret.SubmitLWCXDataResult.IsSuccess)
                        {
                            RefreshLWCXHome();
                        }
                        else
                        {
                            api.alert({
                                title: '错误',
                                msg: ret.SubmitLWCXDataResult.Message,
                            }, function(ret, err){
                            });
                            $("#btnSaveLWCX").removeClass("weui_btn_default");
                            $("#btnSaveLWCX").addClass("weui_btn_primary");
                        }
                    } else {
                      
                        $("#btnSaveLWCX").removeClass("weui_btn_default");
                        $("#btnSaveLWCX").addClass("weui_btn_primary");
                    }
                },
                error: function(data, status, e) {
                        alert('回调方法错误'+e);
                }
        });
    }

    function RefreshLWCXHome()
    {
        api.openWin({
            name: 'win_lwcxhome',
            url: 'win_lwcxhome.html',
            bounces: false,
            delay: 200,
            reload:true,
        });

        api.closeWin({
            name: 'win_lwcxjyxm',
            url: 'win_lwcxjyxm.html',
        });
    }

    function AddHGXM(obj)
    {
        var thisObj = $(obj);
        $("input[name='"+obj.name+"']").parent().attr("style","color:black;");
        var isChecked = $(obj).is(':checked');
         if(isChecked)
         {
            $("#divSub" + thisObj.val()).hide();

            $(obj).parent().attr("style","color:black;");
            var vSelected = $(obj).val();
           
            var index_HGXM = $.inArray(vSelected, chkHGXM); 
            if (index_HGXM < 0) {
                 chkHGXM.push(vSelected); 
                
            }    

            var index_BHGX = $.inArray(vSelected, chkBHGX); 
            if (index_BHGX >= 0) {
                chkBHGX.splice($.inArray(vSelected,chkBHGX),1);
            }

            var index_PBXM = $.inArray(vSelected, chkPBXM); 
            if (index_PBXM >= 0) {
                chkPBXM.splice($.inArray(vSelected,chkPBXM),1);
            }  

            var vParID = thisObj.val();
            for(var i=chkBHGX_SUB.length-1;i>=0;i--)
            {
                var vCurId = chkBHGX_SUB[i].split('-')[0];
                if(vParID == vCurId)
                {
                    $("#chk" + chkBHGX_SUB[i]).removeAttr("checked");
                    chkBHGX_SUB.splice($.inArray(chkBHGX_SUB[i],chkBHGX_SUB),1); 
                }
            }
         }
        ChangedItems();
    }

    function AddBHGX(obj)
    {
        var thisObj = $(obj); 

        thisObj.parent().attr("style","color:black;");
        var isChecked =thisObj.is(':checked');
        if(isChecked)
        {
            $("#divSub" + thisObj.val()).show();

            thisObj.parent().attr("style","color:red;");
            var vSelected = thisObj.val(); 

            var index_HGXM = $.inArray(vSelected, chkHGXM); 
            if (index_HGXM >= 0) {
                chkHGXM.splice($.inArray(vSelected,chkHGXM),1);
            } 

            var index_PBXM = $.inArray(vSelected, chkPBXM); 
            if (index_PBXM >= 0) {
                chkPBXM.splice($.inArray(vSelected,chkPBXM),1);
            }  

            var index_BHGX = $.inArray(vSelected, chkBHGX); 
            if (index_BHGX < 0) {
                chkBHGX.push(vSelected); 
            }
        }
        ChangedItems();
    }

    function ChangedItems(obj)
    {
        var vHGXM = "";
        for(var i=0;i<chkHGXM.length;i++)
        {
            vHGXM += chkHGXM[i]+",";
        }
        $("#txtHGXM").val(vHGXM);

        var vBHGX = "";
         for(var i=0;i<chkBHGX.length;i++)
        {
            vBHGX += chkBHGX[i]+",";
        }
        $("#txtBHGX").val(vBHGX);

        var vBHGX_Sub = "";
        for(var i=0;i<chkBHGX_SUB.length;i++)
        {
            vBHGX_Sub += chkBHGX_SUB[i]+",";
        }
        $("#txtBHGX_Sub").val(vBHGX_Sub);

        var vPBXM = "";
        for(var i=0;i<chkPBXM.length;i++)
        {
            vPBXM += chkPBXM[i]+",";
        }
        $("#txtPBXM").val(vPBXM);
    }

    function AddBHGX_Sub(obj)
    {
        var thisObj = $(obj);
        var vSelected = $(obj).val(); 

        thisObj.parent().attr("style","color:black;");
        var isChecked =thisObj.is(':checked');
        if(isChecked)
        {
            var index_BHGX_Sub = $.inArray(vSelected, chkBHGX_SUB); 
            if (index_BHGX_Sub < 0) {
                chkBHGX_SUB.push(vSelected); 
            }
        }
        else
        {
            var vSelected = $(obj).val();
            var index_BHGX_Sub = $.inArray(vSelected, chkBHGX_SUB); 
            if (index_BHGX_Sub >= 0) {
                chkBHGX_SUB.splice($.inArray(vSelected,chkBHGX_SUB),1); 
            }
        }
        ChangedItems();
    }

     function AddBPDX(obj)
    {
        var thisObj = $(obj);
        $("input[name='"+obj.name+"']").parent().attr("style","color:black;");
        var isChecked = $(obj).is(':checked');
         if(isChecked)
         {
            $("#divSub" + thisObj.val()).hide();

            $(obj).parent().attr("style","color:blue;");
            var vSelected = $(obj).val();
           
            var index_HGXM = $.inArray(vSelected, chkHGXM); 
            if (index_HGXM >= 0) {
                chkHGXM.splice($.inArray(vSelected,chkHGXM),1);
            }    

            var index_BHGX = $.inArray(vSelected, chkBHGX); 
            if (index_BHGX >= 0) {
                chkBHGX.splice($.inArray(vSelected,chkBHGX),1);
            }

            var index_PBXM = $.inArray(vSelected, chkPBXM); 
            if (index_PBXM < 0) {
                chkPBXM.push(vSelected); 
            }

            var vParID = thisObj.val();
            for(var i=chkBHGX_SUB.length-1;i>=0;i--)
            {
                var vCurId = chkBHGX_SUB[i].split('-')[0];
                if(vParID == vCurId)
                {
                    $("#chk" + chkBHGX_SUB[i]).removeAttr("checked");
                    chkBHGX_SUB.splice($.inArray(chkBHGX_SUB[i],chkBHGX_SUB),1); 
                }
            }
         }
         ChangedItems();
    }

    //保存线号
    function ChangeLineNum()
    {
        var vLineNum = $("#selectLineNum").val();
        $api.setStorage('LineNum', vLineNum);
    }
    function ShowDZQM(obj)
    {
         var thisObj = $(obj);
        var vText = thisObj.html();
        if(vText == "显 示")
        {
            thisObj.html("隐 藏");

            drawingBoard.show();
            drawingBoard.open({
            rect: {
                x: 0,
                y: 50,
                w: api.frameWidth,
                h: 150
            },
            styles: {
                brush: {
                    color: '#000',
                    width: 6
                },
                bgColor: '#ff0'
            },
                fixedOn: api.frameName
            });
        }
        else
        {
            drawingBoard.hide();
            thisObj.html("显 示");
        }
    }

    function SaveDZQM()
    {
        if($("#btnShowDZQM").html() == "隐 藏")
        {
            drawingBoard.save({
            savePath: 'fs://drawingBoard/result.png',
                copyToAlbum: false
            }, function(ret) {

                        var vId = api.pageParam.ID;
                        var vUrlWrite = $api.getStorage('ServerUrlWrite');
                        
                        api.ajax({
                        url: vUrlWrite + '/WcfServices/SaveLWCXDZQMImg/'+vId,
                        method: 'post',
                        headers: {
                            "X-APICloud-AppId": "****",
                        },
                        data: {    
                        files: {
                            "file": ret.absolutePath
                                }
                            }
                        }, function(ret, err) {
                        if (ret.IsSuccess) {
                            alert("保存成功！");
                            }
                        });
            });
        }
    }

    function ClearDZQM()
    {
          drawingBoard.clear();
    }
</script>